import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from BasePage.BasePage import BasePage
from Page.put_goods_page import PutGoods


class Main(BasePage):
    __goods_manager = (By.CSS_SELECTOR, '.el-menu>div:nth-child(3) div>span')
    __goods_put = (By.XPATH, "//*[text()='商品上架']")

    @allure.step('主页')
    def main_page(self):
        # 等待
        self.wait(expected_conditions.element_to_be_clickable(self.__goods_manager))
        # 点击商品管理
        self.find_ele(self.__goods_manager).click()
        # 等待
        self.wait(expected_conditions.element_to_be_clickable(self.__goods_put))
        # 点击商品上架
        self.find_ele(self.__goods_put).click()
        return PutGoods(self.driver)
